/*
 * @Author: taoshiwei
 * @Date: 2019-04-09 14:39:32
 * @Last Modified by: taoshiwei
 * @Last Modified time: 2019-04-29 14:49:44
 *
 * 题库
 */

import request from '@/utils/request'

// 基础题库列表
// export const list = data => request('/questions', 'get', data)
export function loadQuestions(params) {
  return request({
    url: '/questions',
    params
  })
}

// 基础题库详情
// export const detail = data => request(`/questions/${data.id}`, 'get', data)
export function detail(data) {
  return request({
    url: `/questions/${data.id}`,
    method: 'get',
    data
  })
}

// 批量导入题
// export const batch = data => request('/questions/batch', 'post', data)
export function batch(data) {
  return request({
    url: `/questions/batch`,
    method: 'post',
    data
  })
}

// 基础题库添加
// export const add = data => request('/questions', 'post', data)
export function add(data) {
  return request({
    url: `/questions`,
    method: 'post',
    data
  })
}

// 基础题库修改
// export const update = data => request(`/questions/${data.id}`, 'put', data)
export function update(data) {
  return request({
    url: `/questions/${data.id}`,
    method: 'put',
    data
  })
}

// 基础题库删除
// export const remove = data => request(`/questions/${data.id}`, 'delete', data)
export function remove(data) {
  return request({
    url: `/questions/${data.id}`,
    method: 'delete',
    data
  })
}

// 精选题库加入取消
// export const choiceAdd = data =>
//   request(`/questions/choice/${data.id}/${data.choiceState}`, 'patch', data)
export function choiceAdd(data) {
  return request({
    url: `/questions/choice/${data.id}/${data.choiceState}`,
    method: 'patch',
    data
  })
}

// 精选题库列表
// export const choice = data => request('/questions/choice', 'get', data)
export function choice(params) {
  return request({
    url: '/questions/choice',
    method: 'get',
    params
  })
}

// 精选题库上下架
// export const choicePublish = data =>
//   request(`/questions/choice/${data.id}/${data.publishState}`, 'post', data)
export function choicePublish(data) {
  return request({
    url: `/questions/choice/${data.id}/${data.publishState}`,
    method: 'post',
    data
  })
}

// 试题审核
// export const choiceCheck = data =>
//   request(`/questions/check/${data.id}`, 'post', data)
export function choiceCheck(data) {
  return request({
    url: `/questions/check/${data.id}`,
    method: 'post',
    data
  })
}

// 试题审核意见列表
// export const auditOpinions = data =>
//   request(`/questions/${data.id}/auditOpinions`, 'get', data)
export function auditOpinions(data) {
  return request({
    url: `/questions/${data.id}/auditOpinions`,
    method: 'get',
    data
  })
}

// 出题记录
// export const setRecords = data =>
//   request(`/questions/${data.id}/setRecords`, 'get', data)
export function setRecords(data) {
  return request({
    url: `/questions/${data.id}/setRecords`,
    method: 'get',
    data
  })
}

// 组题列表
// export const randoms = data => request('/questions/randoms', 'get', data)
export function randoms(data) {
  return request({
    url: '/questions/randoms',
    method: 'get',
    data
  })
}

// 组题列表删除
// export const removeRandoms = data =>
//   request(`/questions/randoms/${data.id}`, 'delete', data)
export function removeRandoms(data) {
  return request({
    url: `/questions/randoms/${data.id}`,
    method: 'delete',
    data
  })
}
